import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 设备信息
 */
@Entity('device_device')
export class DeviceDeviceEntity extends BaseEntity {
  // 所属设备库
  @Column({ comment: '所属设备库ID', nullable: true })
  deviceLibId: number;

  @Column({ comment: '名称', nullable: true })
  name: string;

  // IMEI
  @Index({ unique: true })
  @Column({ comment: 'imei', nullable: true })
  imei: string;

  // @Index({ unique: true })
  // @Column({ comment: '编号', nullable: true })
  // serialNumber: string;

  @Column({ comment: '密码', nullable: true })
  password: string;

  @Index({ unique: true })
  @Column({ comment: 'ICCID', nullable: true })
  iccid: string;

  @Column({ comment: '入网时间', type: 'datetime', nullable: true })
  networkTime: Date;

  @Column({ comment: '客服电话', nullable: true })
  servicePhone: string;

  @Column({ comment: '常见问题', type: 'text', nullable: true })
  faq: string;

  @Column({ comment: '使用说明', type: 'text', nullable: true })
  instructions: string;

  @Column({ comment: '设备状态', dict: ['在线', '离线'], default: 1 })
  status: number;

  @Column({ comment: '所属租户ID', nullable: true })
  tenantId: number;

  // 绑定的用户
  @Column({ comment: '绑定用户ID', nullable: true })
  userId: number;

  /* 当前设备信息，json格式 */
  @Column({ comment: '当前设备信息', type: 'text', nullable: true })
  deviceInfo: string;

  /* 当前设备模式 */
  @Column({
    comment: '当前设备模式（1:正常,2:F1,3:F2,4:F3,5:校准,6:报警）',
    nullable: true,
  })
  current_mode: number;

  /* 当前设备温度 */
  @Column({
    comment: '当前设备温度',
    nullable: true,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  current_temp: number;

  // 当前设备模式工作模式（1:正常,2:F1,3:F2,4:F3,5:校准,6:报警）
  // @Column({ comment: '当前设备模式工作模式', default: 1 })
  // current_mode_work_mode: number;

  /* 启动温度 */
  @Column({
    comment: '启动温度',
    nullable: true,
    type: 'decimal',

    scale: 2,
  })
  start_temp: number;

  /* 停止温度， 包含小数点的 */
  @Column({
    comment: '停止温度',
    nullable: true,
    type: 'decimal',

    scale: 2,
  })
  stop_temp: number;

  // f1_start_time
  @Column({ comment: 'f1_start_time', nullable: true })
  f1_start_time: number;

  // f1_stop_time
  @Column({ comment: 'f1_stop_time', nullable: true })
  f1_stop_time: number;

  /* f2_timer_high */
  @Column({ comment: 'f2_timer_high', nullable: true })
  f2_timer_high: number;

  /* f2_timer_low */
  @Column({ comment: 'f2_timer_low', nullable: true })
  f2_timer_low: number;

  /* f3_timer_high */
  @Column({ comment: 'f3_timer_high', nullable: true })
  f3_timer_high: number;

  /* f3_timer_low */
  @Column({ comment: 'f3_timer_low', nullable: true })
  f3_timer_low: number;

  // temp_calibration
  @Column({ comment: 'temp_calibration', nullable: true })
  temp_calibration: number;
}
